﻿namespace OpenPms.Controllers;
/// <summary>
/// 登记单和入住单
/// </summary>
[Route("api/[controller]")]
public class OrderController : PmsControllerBase<OrderController>
{
    public OrderController(IServiceProvider serviceProvider) : base(serviceProvider)
    {
    }
    /// <summary>
    /// 是否已经入住
    /// </summary>
    /// <param name="idNo">证件号码</param>
    /// <returns></returns>
    [HttpGet("{idNo}")]
    public Task<bool> IsCheckin(string idNo) => OrderService.IsCheckin(HotelId, idNo);

    /// <summary>
    ///  换房
    /// </summary>
    /// <remarks>
    /// 1. 登记单排房或者换房；
    /// 2. 入住单换房
    /// </remarks>
    /// <param name="q"></param>
    /// <returns></returns>
    [HttpPost(nameof(ChangeRoom))]
    public async Task<VRoom> ChangeRoom(RequestChangeRoom q)
    {
        q.HotelId = HotelId;
        return await OrderService.ChangeRoomAsync(q);
    }
    /// <summary>
    /// 入住
    /// </summary>
    /// <param name="q"></param>
    /// <returns></returns>
    [HttpPost(nameof(CheckIn))]
    public Task CheckIn(RequestCheckIn q) => OrderService.CheckInAsync(HotelId, q);
    /// <summary>
    /// 添加同住人
    /// </summary>
    /// <param name="q"></param>
    /// <returns></returns>
    [HttpPost(nameof(AddMate))]
    public Task AddMate(RequestAddMate q) => OrderService.AddMateAsync(HotelId, q);

    /// <summary>
    ///  获取入住详情，包括联房信息、账单、本入住单的客人简单信息
    /// </summary>
    /// <param name="roomNo">房号</param>
    /// <returns></returns>
    [HttpGet("QueryCheckIn/{roomNo}")]
    public Task<TReservation> QueryCheckIn(string roomNo) => OrderService.QueryCheckInAsync(HotelId, roomNo);
    /// <summary>
    /// 获取客人的证件信息
    /// </summary>
    /// <param name="guestId"></param>
    /// <returns></returns>
    [HttpGet("GetInfoIdCardByGuestId/{guestId}")]
    public Task<InfoIdCard?> GetInfoIdCardByGuestId(Guid guestId) => OrderService.GetInfoIdCardByGuestIdAsync(guestId);
    /// <summary>
    /// 获取客人的证件信息
    /// </summary>
    /// <param name="idno">身份证号码</param>
    /// <returns></returns>
    [HttpGet("GetInfoIdCardByIdNo/{idno}")]
    public Task<InfoIdCard?> GetInfoIdCardByIdNo(Guid idno) => OrderService.GetInfoIdCardByIdNoAsync(idno);

    [HttpPost(nameof(CheckOut))]
    public Task CheckOut(List<Guid> guestIds) => OrderService.CheckOutAsync(HotelId, guestIds);
}

